import tkinter as tk
from typing import Type

from proxy import Container, create_proxy_widget


def registry(container: Type[Container]) -> Type[Container]:
    container.registry('tk.Button', tk.Button)
    container.registry('ProxyLabelFrame', create_proxy_widget(tk.LabelFrame))
    return container


class App(tk.Tk):

    def __init__(self):
        super().__init__()

        width = 800
        height = 600
        screen_width = self.winfo_screenwidth()
        screen_height = self.winfo_screenheight()
        x = screen_width // 2 - width // 2
        y = screen_height // 2 - height // 2

        self.title('tkinter-demo')
        self.geometry(f'{width}x{height}+{x}+{y}')

        registry(Container)(self).parse_file('./ui.json')

    def handle_button1(self):
        print('hello')


if __name__ == '__main__':
    app = App()
    app.mainloop()
   
